< previous page page_106 next page >

Page 106
Private Sub Text1_Click()
    Debug.Print "Text1 Click Event"
End Sub

Private Sub Text1_GotFocus()
    Debug.Print "Text1 Got Focus Event"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Debug.Print "Text1 Keypress Event"
End Sub
Whether you use a tool like this program, or some other method, understanding the sequence of events is critically important. Once you realize that one user action can lead to several events, you can use that information to plan for which events you want to write code. For example, you can use a text box's KeyDown event, which is the first event that occurs when the user presses a key while the text box has the focus, to determine whether the user has pressed Ctrl. That may be an indication within your program of some special action, such as opening a new record or saving initialization information. Whatever the case, you should test your applications thoroughly, using a variety of sequences of actions to your objects, to make sure that unexpected event sequences won't cause undesired results.
From Here . . .
This chapter focused on how Visual Basic handles events. However, events are useful only in the context of forms and controls because they are the objects capable of receiving events. Also, events can cause an action in your program only if some code has been written for the event. You can learn more about these related topics in the following chapters:
See Chapter 3, ''Visual Basic Building Blocks," for introductions to forms, controls, properties, methods, and events.
For further fundamental information on using Visual Basic controls, see Chapter 4, "Using Visual Basic's Default Controls."
Chapter 6, "Giving More Control to the User: Menus and Toolbars," covers menus and toolbars in Visual Basic programs.
For information on the Common Dialog control, see Chapter 7, "Using Dialog Boxes to Get Information."
To find out more about writing your own procedures, see Chapter 11, "Managing Your Project: Sub Procedures, Functions, and Multiple Forms."
To learn about the many different events available in the custom controls, see Chapter 12, "Microsoft Common Controls."

 
< previous page page_106 next page >